using System;
using System.Collections;
using MediaServer.VideoCore;

namespace MediaServer {
    /// <summary>
    /// CameraCollection class
    /// </summary>    
    public class CameraCollection : CollectionBase {
        // Constructor
        public CameraCollection() {
        }

        // Get came at the specified index
        public IPCamera this[int index] {
            get {
                return ((IPCamera)InnerList[index]);
            }
        }

        // Add new camera to the collection
        public void Add(IPCamera camera) {
            InnerList.Add(camera);
        }

        // Remove camera from the collection
        public void Remove(IPCamera camera) {
            InnerList.Remove(camera);
        }

        // Get camera with specified name
        public IPCamera GetCamera(string name) {
            // find the camera
            foreach (IPCamera camera in InnerList) {
                if ((camera.Name == name))
                    return camera;
            }
            return null;
        }

        // Get camera with specified ID
        public IPCamera GetCamera(Guid cameraID) {
            // find the camera
            foreach (IPCamera camera in InnerList) {
                if (camera.ID == cameraID) {
                    return camera;
                }
            }
            return null;
        }
    }
}
